package com.javasm.mingming.login.authorize;

import com.javasm.mingming.login.entity.LoginUserDetails;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;

/**
 * @author javasm
 * @version 0.1
 * @className JavasmMenuAuthorize
 * @descriptioin:
 * @date 2025/1/15 14:54
 * @since jdk11
 */
@Component
public class JavasmMenuAuthorize {

    public boolean check(String url){
        //获取 用户信息
        Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        if (principal != null){
            LoginUserDetails loginUserDetails = (LoginUserDetails) principal;
            return loginUserDetails.checkMenu(url);
        }
        return false;
    }
}
